class Page < ActiveRecord::Base
	validates_presence_of :title, :content
	validates_uniqueness_of :slug
	
	def to_param
		#self.id.to_s + "-" + self.slug if self.id
		self.slug if self.id
	end
	
	def before_save
		self.slug = self.title.parameterize if self.slug.blank?
	end
	
	def self.what_is_it
		#@@what_is_it ||= Page.find_by_type(PageType::WHAT_IS_IT)
		@@what_is_it ||= Page.find_by_title(PageType.find(PageType::WHAT_IS_IT).name)
		@@what_is_it
	end
	
	def self.help
		#@@help ||= Page.find_by_type(PageType::HELP)
		@@help ||= Page.find_by_title(PageType.find(PageType::HELP).name)
		@@help
	end
	
	def self.find_by_type(_type)
		find(:first, :conditions=>{:page_type_id=>_type})
	end
end
